package com.extra;

public class Solution1221 {
    public int balancedStringSplit(String s) {
        int i = 0;
        int j = 0;
        int count = 0;
        for (int k = 0; k < s.length(); k++) {
            if (s.charAt(k) == 'R') i++;
            else j++;
            if (i != 0 && i == j) {
                count++;
                i = 0;
                j = 0;
            }
        }
        return count;
    }
}
